package com.aji.mapper;

import com.aji.dto.Ores3AddDto;
import com.aji.dto.Ores3ChangeDto;
import com.aji.entity.Ores1;
import com.aji.entity.Ores1Select;
import com.aji.entity.Ores2;
import com.aji.entity.Ores3;
import com.aji.vo.Ores3Vo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface LocMapper {
    @Select("select * from ores_1")
    List<Ores1> selectOres1();
//    @Select("select * from ores_2 where ores_1_id=#{ores1Id}")
    List<Ores2> selectOres2ByOres1(Integer ores1Id);
//    @Select("select * from ores_3 where ores_2_id=#{ores2Id}")
    List<Ores3> selectOres3ByOres2(@Param("ores1Id") Integer ores1Id,@Param("ores2Id") Integer ores2Id);
    @Update("update ores_1 set ores_1_name = #{ores1Name} where ores_1_id = #{ores1Id}")
    void upDateOres1ById(@Param("ores1Id") Integer ores1Id, @Param("ores1Name") String ores1Name);
    @Update("update ores_2 set ores_2_name = #{ores2Name} where ores_2_id = #{ores2Id}")
    void upDateOres2ById(@Param("ores2Id")Integer ores2Id, @Param("ores2Name")String ores2Name);

    void upDateOres3ById(Ores3 ores3);
    @Insert("insert into ores_1(ores_1_name)value(#{ores1Name})")
    void addOres1(@Param("ores1Name") String ores1Name);
    @Insert("insert into ores_2(ores_2_name,ores_1_id)value(#{ores2Name},#{ores1Id})")
    void addOres2(@Param("ores2Name")String ores2Name,@Param("ores1Id") Integer ores1Id);
    void addOres3(Ores3 ores3);

    void deleteByIds1(List<Integer> ids);

    void deleteByIds3(List<Integer> ores3Ids);

    void deleteByIds2(List<Integer> ores2Ids);

    Ores3Vo selectOres3ById(Integer ores3Id);

    List<Ores1Select> selectAll();
    @Select("select ores_3_id from ores_3 where ores_3_name = #{ores3AddDto.name} LIMIT 1;")
    Integer selectOres3IdByCon(@Param("ores3AddDto")Ores3AddDto ores3AddDto);

    @Select("select ores_3_name from ores_3 where ores_3_id = #{id}")
    String selectOres3Name(Integer id);
    @Select("select * from ores_2")
    List<Ores2> selectOres2();
    @Select("select * from ores_3")
    List<Ores3> selectOres3();
}
